package com.wht.mapper.music.impl;

import com.wht.mapper.music.AddMusicDao;
import com.wht.domain.Music;
import com.wht.utils.JDBCUtils;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @author wanghaotian
 * time:2022/11/21,0021 21:43
 * description:
 */

public class AddMusicDaoImpl implements AddMusicDao {
    private JdbcTemplate jt = new JdbcTemplate(JDBCUtils.getDs());
    @Override
    public int insertMusic(Music music) {
        try {
            String sql = "insert into music values (null,?,?,?) ";
            int update = jt.update(sql, music.getName(), music.getSid(), music.getAlbum());
            return update;
        } catch (DataAccessException e) {
            return 0;
        }
    }
}
